package chapter04.demo1;
//定义Animal类
class Animal6{
    private String name6;
    private  int age6;
    public Animal6(String name6, int age6){
        this.name6=name6;
        this.age6=age6;
    }
    public String getName6(){
        return name6;
    }
    public void setName6(String name6){
        this.name6=name6;
    }
    public int getAge6(){
        return age6;
    }
    public void  setAge6(int age6){
        this.age6=age6;
    }
    public String info(){
        return "名称："+this.getName6()+",年龄："+this.getAge6();
    }
}
//定义Dog6类继承Animal6类
class  Dog6 extends Animal6{
    private String color;
    public Dog6(String name6,int age6,String color){
        super(name6,age6);
        this.setColor(color);
    }
    public String getColor(){
        return color;
    }
        public void setColor(String color){
            this.color=color;
        }
   //重写父类的info()方法
    public String info(){
        return super.info()+"颜色:"+this.getColor();//扩充父类中的方法
    }
//}
//定义测试类
//public class example6{
    public static void main(String[] args){
        Dog6 dog6=new Dog6("牧羊犬",3,"黑色");//创建Dog类的实例对象
        System.out.println(dog6.info());
    }
}
